package go_leetcode

func countPoints(rings string) int {
    ans := 0
    state := [10][3]int{}
    n := len(rings)
    for i := 0; i < n; i += 2 {
        color := rune(rings[i])
        poleIndex := rings[i+1] - '0'
        state[poleIndex][getColorId(color)] = 1
    }
    for i := 0; i < 10; i++ {
        flag := true
        for j := 0; j < 3; j++ {
            if state[i][j] == 0 {
                flag = false
                break
            }
        }
        if flag {
            ans++
        }
    }
    return ans
}

func getColorId(color rune) int{
    if color == 'R' {
        return 0
    } else if color == 'G' {
        return 1
    }
    return 2
}